﻿#Region "Algorithms"
'Title: Temperature Conversion
'Author: Greg Cronk
'Date: 2/11/2014
'Course & Section: CSC 162-401
'Description: Program to convert temperature from F to C
'Initial Algorithm:  User Inputs data into txtF as temperature in F
'                    txtF is assigned as the value of TempF 
'                    Insert TempF into the forumula (TempF-32) * (5/9)
'                    Output Solution of the above Forumla in txtC
'Data Requirements: 

' Input Variables : Temperature in F
'                   Button Click to initalize the calculation
' Output Variables: Temperature in C
' Addition Variables: None

'Formulas: (F-32) * (5/9)

' List any calculations the Procedure/Function performs
' This does not include comparisons
' This Program uses the above formula to convert temperature in F to C

' Refined Algorithm: In each Sub Procedure

#End Region


Public Class frmTempConverter
    ' If the txtF or txtC Box has content Then Clear the Content for a new calculation
    Private Sub btnClear_Click(sender As System.Object, e As System.EventArgs) Handles btnClear.Click
        ' Resets or "Clears" the Entry boxes so a new calculation can be preformed.
        txtF.Text = ""
        txtC.Text = ""
    End Sub

    Private Sub btnExit_Click(sender As System.Object, e As System.EventArgs) Handles btnExit.Click
        ' Closes the Form Window and released it from System Memory
        Me.Close()
        End
    End Sub

    Private Sub btnConvert_Click(sender As System.Object, e As System.EventArgs) Handles btnConvert.Click
        ' Declare Varibles.
        Dim TempF As Integer ' Reserves Memory for TempF
        Dim TempC As Integer ' Reserves Memory for TempC

        ' Assign Values
        ' Temperature value in txtF is checked to assure it is a numeric value
        ' If Value of txtF.text is not numeric Then txtF.Text = 0
        ' Doing this prevents the program from crashing
        ' Temperature in txtF text box is assigned to the varible TempF
        ' TempF is inputed into the formula (TempF - 32) * (5/9) and the calculated result is assigned to TempC
        ' Calculated value of TempC is displayed in txtC.Text

        TempF = Val(txtF.Text) 'Sets the Data in txtF as the value of TempF
        TempC = (TempF - 32) * (5 / 9) 'Preforms the Calculation now that TempF has an assigned value in memory
        txtC.Text = TempC 'Outputs the value of TempC in the Text Box
    End Sub
End Class
